import request from '@/utils/request'

export function getRoutes() {
  return request({
    url: '/api/sysMenu/list',
    method: 'get'
  })
}

export function getRoleList() {
  return request({
    url: '/api/sysRole/list',
    method: 'get'
  })
}

export function getRoles(data) {
  return request({
    url: '/api/sysRole/page',
    method: 'post',
    data
  })
}

export function addRole(data) {
  return request({
    url: '/api/sysRole/add',
    method: 'post',
    data
  })
}

export function updateRole(data) {
  return request({
    url: '/api/sysRole/update',
    method: 'post',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: '/api/sysRole/delete',
    method: 'post',
    data: { id }
  })
}

export function ownMenuList(id) {
  return request({
    url: '/api/sysRole/ownMenuList',
    method: 'get',
    params: { id }
  })
}

export function ownRoleList(id) {
  return request({
    url: `/api/sysUser/ownRoleList/${id}`,
    method: 'get'
  })
}

export function updateScope(data) {
  return request({
    url: '/api/sysRole/grantDataScope',
    method: 'post',
    data
  })
}
